import http from '@/utils/http'

const BASE_URL = '/generator/favorites'

export interface FavoritesResp {
  id: string
  userId: string
  favoriteType: string
  equipmentId: string
  createTime: string
  updateTime: string
  createUserId: string
  createUserString: string
  updateUserString: string
}
export interface FavoritesDetailResp {
  id: string
  userId: string
  favoriteType: string
  equipmentId: string
  createTime: string
  updateTime: string
  createUserId: string
  createUserString: string
  updateUserString: string
}
export interface FavoritesQuery {
  favoriteType: string
  createUserId: string
  sort: Array<string>
}
export interface FavoritesPageQuery extends FavoritesQuery, PageQuery {}

/** @desc 查询我的收藏列表 */
export function listFavorites(query: FavoritesPageQuery) {
  return http.get<PageRes<FavoritesResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询我的收藏详情 */
export function getFavorites(id: string) {
  return http.get<FavoritesDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增我的收藏 */
export function addFavorites(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改我的收藏 */
export function updateFavorites(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除我的收藏 */
export function deleteFavorites(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出我的收藏 */
export function exportFavorites(query: FavoritesQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}

/** @desc 查询我的收藏列表 */
export function getCollectList(query: FavoritesPageQuery) {
  return http.get(`contects`, query)
}
